<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../themes/gray/easyui.css" />
<link rel="stylesheet" href="../../themes/icon.css" />
<link rel="stylesheet" href="../../themes/general.css" />
<link rel="stylesheet" href="../../themes/jquery-ui.css" />
<script type="text/javascript" src="../../scripts/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../../scripts/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="../../scripts/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	$(function() {
		$('#moduleManageGrid')
				.datagrid(
						{
							title : '日报周报列表',
							//iconCls: 'icon-save',
							//width: 800,
							height : 562,
							collapsible : false,
							//url: '../../journal/getJournal.ajax',
							frozenColumns : [ [ {
								field : 'ck',
								checkbox : true
							}, {
								title : '项目名',
								field : 'pname',
								width : 180
							} ] ],
							columns : [ [
									{
										field : 'type',
										title : '类型',
										width : 100,
										formatter : function(value, row, index) {
											if (value == 0) {
												return '日报';
											} else if (value == 1) {
												return '周报';
											} else {
												return '月报';
											}
										}
									},
									{
										field : 'posttime',
										title : '上传日期',
										width : 100,
										sortable : true,
										sorter : function(sort, order) {
											alert(sort + " " + order);
										}
									},
									{
										field : 'jTime',
										title : '日志日期',
										width : 100
									},
									{
										field : 'week',
										title : '周',
										width : 100
									},
									{
										field : 'status',
										title : '状态',
										width : 100,
										formatter : function(value, row, index) {
											if (value == 0) {
												return '未审核';
											} else if (value == 1) {
												return '已审核';
											}
										}
									},
									{
										field : 'postName',
										title : '上传人',
										width : 100
									},
									{
										field : 'file',
										title : '附件',
										width : 100
									},
									{
										field : 'download',
										title : '操作',
										width : 100,
										formatter : function(value, row, index) {
											return '<a href="javascript:void(0)" onclick="downloadFile('
													+ index + ')">下载附件</a>';
										}
									} ] ],
							pagination : true,
							rownumbers : true,
							toolbar : [ {
								id : 'btnEdit',
								text : '编辑报表',
								iconCls : 'icon-cut',
								handler : function() {
								}
							}, '-', {
								id : 'btnDelete',
								text : '删除报表',
								disabled : true,
								iconCls : 'icon-save',
								handler : function() {
								}
							} ]
						});

		function SearchTrainee(pageNumber, pageSize) {
			var dg = $('#moduleManageGrid');
			var opts = dg.datagrid('options');
			var pager = dg.datagrid('getPager');
			//异步获取数据到javascript对象，入参为查询条件和页码信息  
			$.post('../../journal/getJournal.ajax', {
				page : pageNumber,
				rows : pageSize,
			}, function(data) {
				//注意此处从数据库传来的data数据有记录总行数的total列  
				var total = JSON.parse(data).total;
				dg.datagrid('loadData', JSON.parse(data).list);
				pager.pagination({
					//更新pagination的导航列表各参数  
					total : total, //总数  
					pageSize : pageSize, //行数  
					pageNumber : pageNumber
				//页数  
				});
			});
		}
		SearchTrainee(1, 10);
		$('#moduleManageGrid').datagrid('getPager').pagination({
			onChangePageSize : function() {
				//alert('pagesize changed');
			},
			onSelectPage : function(pageNumber, pageSize) {
				SearchTrainee(pageNumber, pageSize); //每次更换页面时触发更改   
				alert(pageNumber + " " + pageSize);
			}
		});
	});

	function downloadFile(index) {
		var row = $('#moduleManageGrid').datagrid('getData').rows[index];
		//生成的文件名
		var filename = row.jTime;
		var name = row.file;
		alert(filename + "  " + name);
		window.location.href = "../../journal/downloadJournal.ajax?filename="
				+ filename + "&name=" + name;
	}
</script>
<title>日志列表</title>
</head>

<body>
	<div style="margin: 10px 0;"></div>
	<div style="margin: 0 5px">
		<table class="table_view"
			style="font-size: 12px; background: #FAFAFA;">
			<tr>

				<td class="td_view_name_people">日志类型</td>
				<td class="td_view_value_people"><select id="cc"
					class="easyui-combobox" name="dept" style="width: 150px;">
						<option value="aa">日报</option>
						<option>周报</option>
				</select></td>
				<td class="td_view_name_people">项目名称</td>
				<td class="td_view_value_people"><input class="easyui-combobox"
					id="projectNameSelect" name="projectNameSelect" /></td>
			</tr>
		</table>
		</form>
		<div style="margin: 10px 0;"></div>
		<div style="margin: 0 5px">

			<div style="width: 100%; height: 100%;">
				<table id="moduleManageGrid"></table>
			</div>

		</div>
</body>

</html>